<?php
class Application_Model_DbTable_Anime extends Zend_Db_Table_Abstract
{
    protected $_name = 'anime';
    
    public function getAnimeList ()
    {
        $select = $this->select();
        $select->from($this, array('id', 'title'))->order('title ASC');
        $rows = $this->fetchAll($select);
        return $rows;
    }
    
    public function getAnime ($id = 0)
    {
        $select = $this->select();
        $select->where("id={$id}");
        $row = $this->fetchRow($select);
        return $row;
    }
    
    public function getGenres ($id = 0)
    {
        $db = Zend_Db_Table_Abstract::getDefaultAdapter();
		$stmt = $db->query('Select gt.genre_name From genre_type gt join genres g on g.genre_id=gt.genre_id where g.anime_id=6');
        $rows = $stmt->fetchAll();
        return $rows;
    }
    
	public function getProducers ($id = 0)
    {
        $db = Zend_Db_Table_Abstract::getDefaultAdapter();
		$stmt = $db->query('Select pn.prod_name From producer_names pn join producers p on pn.prod_id=p.producer_id where p.anime_id=6');
        $rows = $stmt->fetchAll();
        return $rows;
    }
}

